package org.neuedu.fly.entity.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResponseEntity {
    private int code;
    private Long count;
    private String msg;
    private Object data;

    public static ResponseEntity ok(String msg) {
        return new ResponseEntity(0, null, msg, null);
    }

    public static ResponseEntity ok() {
        return new ResponseEntity(0, null, null, null);
    }

    public static ResponseEntity error(String msg) {
        return new ResponseEntity(1, null, msg, null);
    }

    public static ResponseEntity page(long count, Object data) {
        return new ResponseEntity(0, count, null, data);
    }

    public static ResponseEntity data(Object data) {
        return new ResponseEntity(0, null, null, data);
    }

    public static boolean isSuccess(ResponseEntity responseEntity) {
        return responseEntity.getCode() == 0;
    }
}